<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>教学管理系统_登录</title>
<style type="text/css">
        .code
        {
            background-image:url(code.jpg);
            font-family:Arial;
            font-style:italic;
            color:Red;
            border:0;
            padding:2px 3px;
            letter-spacing:3px;
            font-weight:bolder;
        }
        .unchanged
        {
            border:0;
        }
    </style>

<script type="text/javaScript">
 var code ; //在全局 定义验证码

	function submitForm()
	{
	  if(!validate())
		return false;
	  
	  if(document.form1.userName.value=="")
        {
           alert("请输入用户名");
           document.form1.userName.focus();
           return false;
        }else if(document.form1.userPassword.value=="")
        {
           alert("请输入密码");
           document.form1.userPassword.focus();
           return false;
        }else
        {
            document.form1.action="checkUser";
          return true;
		}
	}



     function createCode()
     { 
       code = "";
       var codeLength = 6;//验证码的长度
       var checkCode = document.getElementById("checkCode");
       var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');//所有候选组成验证码的字符，当然也可以用中文的
        
       for(var i=0;i<codeLength;i++)
       {
      
        
       var charIndex = Math.floor(Math.random()*36);
       code +=selectChar[charIndex];
       
       
       }
//       alert(code);
       if(checkCode)
       {
         checkCode.className="code";
         checkCode.value = code;
       }
       
     }
     
      function validate ()
     {
       var inputCode = document.getElementById("input1").value;
       if(inputCode.length <=0)
       {
           alert("请输入验证码！");
		   return false;
       }
       else if(inputCode != code )
       {
          alert("验证码输入错误！");
          createCode();//刷新验证码
		  return false;
       }
       else
       {
       	return true;
       }
    
       
       }
</script>
</head>

<body bgcolor="#52BDFE" onload="createCode()">
<table height="100%" width="100%">
	<tr>
    	<td align="center">
        <table width="1100" height="600" align="center" background="images/background.jpg">
        	<tr>
            	<td width="60%"></td>
                <td>
                	<form name="form1" method="post">
						<table>
								<tr>
    								<td>用户名：</td>
        							<td><input type="text" name="userName" size=10></td>
    							</tr>
								<tr>
    								<td>密&nbsp;&nbsp;&nbsp;码：</td>
      				  		<td><input type="password" name="userPassword" size=10></td>
   							</tr>
                <tr>
                    <td>用户类型</td>
                    <td><select name="userType" size="1">
                      <option value="1" selected>学生</option>
                      <option value="2">老师</option>
                      <option value="3">助教</option>
                      </select></td>
                </tr>
				</tr>
				<td>
				验证码：
				</td>
				<td>
				<input  type="text"   id="input1" style="width: 100px"/>
				</td>
				<td>
				<input type="text" onclick="createCode()" readonly="readonly" id="checkCode" class="unchanged" style="width: 100px"  />
				</td>
				</tr>

    						<tr>
                    <td></td>
                    <td >
      					<input type="submit" name="submit" onclick="submitForm()" value="登录">
                        <input type="reset" name="reset" value="重置">
                    </td>
                    <td >
                      <a href="confirm.html">注册新用户</a>
                    </td>
    						</tr>
						</table>
					</form>
                </td> 
            </tr>
        </table>
      </td>
    </tr>
</table>
</body>
</html>
